#if UNITY_EDITOR
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sirenix.OdinInspector;
using UnityEditor.Experimental.GraphView;

namespace Ease.EaseNode.Runtime
{
    public enum NodeState
    {
        [LabelText("未执行")] None,
        [LabelText("激活")] Start,
        [LabelText("正在执行")] Running,
        [LabelText("执行完成")] Finish,
    }

    public static class PortUtil
    {
        public static string CreateName(string head, string key, int portId)
        {
            return $"{head}_{key}_{portId}";
        }

        public static bool GetInfoFromPortName(string portName, out string key, out string portId)
        {
            var temp = portName.Split("_");
            if (temp.Count() < 3)
            {
                key = string.Empty;
                portId = string.Empty;
                return false;
            }

            key = temp[1];
            portId = temp[2];
            return true;
        }
    }

    public class PortConfig
    {
        public int id;
        public string portName;
        public Port.Capacity capacity;

        public string CreateName(string head, string key)
        {
            return PortUtil.CreateName(head, key, id);
        }
    }

    [Serializable]
    public class PortInfo
    {
        public string portName;
        public List<string> portNames = new List<string>();

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder(portName);
            sb.Append(":");
            foreach (var name in portNames)
            {
                sb.Append(name);
                sb.Append(" ");
            }

            return sb.ToString();
        }

        public static bool GetInfoFromPortName(string portName, out string key, out string id)
        {
            return PortUtil.GetInfoFromPortName(portName, out key, out id);
        }
    }
}
#endif